﻿using System;

namespace FallingRox
{
    public class MatrixCoords
    {
        public int Row { get; set; }

        public int Col { get; set; }

        public MatrixCoords(int row, int col)
        {
            this.Row = row;
            this.Col = col;
        }

        public static MatrixCoords operator +(MatrixCoords a, MatrixCoords b)
        {
            return new MatrixCoords(a.Row + b.Row, a.Col + b.Col);
        }

        public static MatrixCoords operator -(MatrixCoords a, MatrixCoords b)
        {
            return new MatrixCoords(a.Row - b.Row, a.Col - b.Col);
        }

        public static bool operator ==(MatrixCoords a, MatrixCoords b)
        {
            return a.Equals(b);
        }

        public static bool operator !=(MatrixCoords a, MatrixCoords b)
        {
            return !(a.Equals(b));
        }

        public override bool Equals(object obj)
        {
            MatrixCoords objMat = obj as MatrixCoords;
            return objMat.Row == this.Row && objMat.Col == this.Col;
        }

        public override int GetHashCode()
        {
            return this.Row.GetHashCode() * 7 + this.Col;
        }
    }
}
